package main

import "fmt"

type Human struct {
	name  string
	age   int
	phone string
}
type Student struct {
	Human
	school string
	loan   float32
}
type Employee struct {
	Human
	company string
	money   float32
}

//Human实现SayHi方法
func (h Human) SayHi() {
	fmt.Printf("Hi,I am %s you can call on %s\n", h.name, h.phone)
}

//Human实现Sing方法
func (h Human) Sing(lyrics string) {
	fmt.Println("La la la la la...", lyrics)
}

//Employee重载Human的SayHi方法
func (e Employee) SayHi() {
	fmt.Printf("Hi,I am %s,I work at %s.Call me on %s\n", e.name, e.company, e.phone)
}

type Men interface {
	SayHi()
	Sing(lyrics string)
}

func main() {
	mike := Student{Human{"Mike", 25, "222-222-xxx"}, "MIT", 0.00}
	paul := Student{Human{"Paul", 26, "111-222-xxx"}, "ISC", 100}
	sam := Employee{Human{"Sam", 36, "444-222-xxx"}, "Golang Inc", 1000}
	tom := Employee{Human{"Tom", 37, "222-444-xxx"}, "Things Ltd.", 5000}
	var i Men
	i = mike
	fmt.Println("this is Mike, a student:")
	i.SayHi()
	i.Sing("November rain")
	i = tom
	fmt.Println("this is tom,an Employee:")
	i.SayHi()
	i.Sing("Born to be wild")
	fmt.Println("Let's use a slice of Men and see what happends")
	x := make([]Men, 3)
	x[0], x[1], x[2] = paul, sam, mike
	for _, value := range x {
		value.SayHi()
	}
}
